home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Treccani Italiana Di Scienze Lettere Ed Arti
/
[Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso
/
pc
/
data
/
menu_dvd.swf
/
scripts
/
__Packages
/
EmbedHtmlMenuCellRenderer.as
< prev
next >
Wrap
Text File
|
2007-11-07
|
4KB
|
146 lines
class EmbedHtmlMenuCellRenderer extends mx.core.UIComponent
{
static var style_sheet = null;
var previousLabel = null;
function EmbedHtmlMenuCellRenderer()
{
super();
this.cssStyle = "menuRowTextEmbed";
}
function createChildren(Void)
{
if(this.htmlComponent == undefined)
{
this.createLabel("htmlComponent",1);
}
this.htmlComponent.html = true;
this.htmlComponent.border = false;
this.htmlComponent.multiline = false;
this.htmlComponent.wordWrap = false;
this.htmlComponent.selectable = false;
this.htmlComponent.styleSheet = EmbedHtmlMenuCellRenderer.style_sheet;
this.htmlComponent.embedFonts = true;
this.htmlComponent.antiAliasType = "advanced";
this.htmlComponent.sharpness = -300;
this.htmlComponent.thickness = -50;
this._parent.drawRowFill = this.drawRowFill;
this.size();
}
function size(Void)
{
this.htmlComponent.setSize(this.__width,this.__height - 2);
var deltaY = 2;
if(EmbedHtmlMenuCellRenderer.style_sheet)
{
var style = EmbedHtmlMenuCellRenderer.style_sheet.getStyle("." + this.cssStyle);
if(style)
{
deltaY = Math.max(0,Math.floor((this.__height - style.fontSize - 1 - 2) / 2));
}
}
trace(deltaY);
this.htmlComponent._y = deltaY;
}
function setValue(str, item, sel)
{
if(item == undefined)
{
this.htmlComponent.htmlText = str;
this.previousLabel = null;
return undefined;
}
var columnIndex = this.columnIndex;
var columnName = this.getDataLabel();
var htmlTxt = str;
var labelSupSub = this.HtmlFunction(item.label);
htmlTxt = "<span class=\'" + this.cssStyle + "\'>" + labelSupSub + "</span>";
this.htmlComponent.htmlText = htmlTxt;
if(item.cellEnabled == false && !this.disableRect)
{
this.disableRect = this.createRectangle(-2,0,this.__width + 2,this.__height + 1,16777215,"disableRect");
this.disableRect.onPress = function()
{
};
this.disableRect.useHandCursor = false;
this.disableRect._alpha = 30;
this.setColor(this.owner.getStyle("disabledColor"));
}
if(item.cellEnabled == true && this.disableRect)
{
this.disableRect._visible = false;
}
}
function createRectangle(inX, inY, w, h, bgColor, name)
{
var mc = this.createEmptyMovieClip(name,this.getNextHighestDepth());
mc.beginFill(bgColor);
mc.lineTo(w,0);
mc.lineTo(w,h);
mc.lineTo(0,h);
mc.lineTo(0,0);
mc._x = inX;
mc._y = inY;
return mc;
}
function getPreferredHeight(Void)
{
if(this.owner == undefined)
{
return 18;
}
return this.owner.__height;
}
function HtmlFunction(inLabel)
{
if(inLabel.indexOf("<sup>") >= 0 || inLabel.indexOf("<sub>") >= 0)
{
return StringUtils.subSupFromHTML(inLabel);
}
return inLabel;
}
function setColor(col)
{
if(this.htmlComponent != undefined)
{
this.htmlComponent.textColor = col;
}
}
function drawRowFill(mc, newClr)
{
mc.clear();
mc.beginFill(16777215);
mc.drawRect(0,0,this.__width,this.__height);
mc.beginFill(newClr);
mc.drawRect(0,1,this.__width,this.__height);
mc.endFill();
mc._width = this.__width;
mc._height = this.__height;
mc._alpha = 90;
}
static function displayStyleSheet(my_styleSheet)
{
var styleNames = my_styleSheet.getStyleNames();
if(!styleNames.length)
{
trace("This is an empty style sheet.");
}
else
{
var i = 0;
while(i < styleNames.length)
{
var styleName = styleNames[i];
trace("Style " + styleName + ":");
var styleObject = my_styleSheet.getStyle(styleName);
for(var propName in styleObject)
{
var propValue = styleObject[propName];
trace("\t" + propName + ": " + propValue);
}
trace("");
i++;
}
}
}
}